package com.itboye.sunsun.adapter;

import java.util.List;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.itboye.sunsun.application.App;
import com.itboye.sunsun.beans.MyTieZiMeBean.TieZibean;
import com.itboye.sunsun.beans.WoDeHuiTieBean.WoDeHuiTieItemBean;
import com.itboye.sunsunhome.R;

public class MeMyTieziAdaptyer extends BaseAdapter {

	// private Context context;
	private List<TieZibean> list;
	

	public MeMyTieziAdaptyer(List<TieZibean> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub

		return list == null ? 0 : list.size();

	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("NewApi")
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		ViewHolder viewHolder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(App.ctx).inflate(
					R.layout.item_shop_banner, null);

			viewHolder = new ViewHolder();
			viewHolder.imagestate = (Button) convertView
					.findViewById(R.id.stateimagein);
			viewHolder.name = (TextView) convertView.findViewById(R.id.name);
			viewHolder.pinluncountTime = (TextView) convertView
					.findViewById(R.id.pinluncountTime);
			viewHolder.pinluncount = (TextView) convertView
					.findViewById(R.id.pinluncount);
			viewHolder.imagestaterela = (RelativeLayout) convertView
					.findViewById(R.id.stateimageinrela);
			viewHolder.tvShoucangJing = (TextView) convertView
					.findViewById(R.id.tvShoucangJing);
			viewHolder.tvcountext = (TextView) convertView
					.findViewById(R.id.tvcountext);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.name.setText(list.get(position).getSubject());
		viewHolder.pinluncountTime.setText(list.get(position)
				.getDateline_show());
		viewHolder.pinluncount.setText(list.get(position).getReplies());
		viewHolder.tvcountext.setText(list.get(position).getName());
		if (list.get(position).getStatus().equals("0")) {
			viewHolder.tvShoucangJing.setVisibility(View.GONE);
		} else if (list.get(position).getStatus().equals("1")) {
			viewHolder.tvShoucangJing.setVisibility(View.GONE);
		}

		return convertView;
	}

	class ViewHolder {
		TextView name, tvcountext;
		TextView abstracttext;
		TextView pinluncountTime;
		TextView pinluncount;
		Button imagestate;
		TextView tvShoucangJing;
		RelativeLayout imagestaterela;
	}

}
